package com.chao.product.conf;

import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyReturnCallback implements RabbitTemplate.ReturnsCallback {

    //回退模式 publisher-return模式可以在消息没有被路由到指定的queue时将消息返回
    @Override
    public void returnedMessage(ReturnedMessage returnedMessage) {
        System.out.println("回退消息: ReturnsCallback:" + new String(returnedMessage.getMessage().getBody()));
    }
}
